import store from '../../../../store'
import { changeRotation } from 'assets/js/CesiumFun/CesiumPubFun/modelControl'

// 左旋转
function cameraLeft() {
    var collection = store.state.camera.cameraCollection;// 所有存储的摄像头
    var id = store.state.camera.cameraId// 当前选中的摄像头id
    var searchedCamera =  searchCamera(collection, id);// 找到当前摄像头
    // 改变角度
    changeRotation(searchedCamera, searchedCamera.asset.extras[0].Position,
         searchedCamera.asset.extras[0].rotation -= 25)
}

// 右旋转
function cameraRight() {
    var collection = store.state.camera.cameraCollection;
    var id = store.state.camera.cameraId
    var searchedCamera =  searchCamera(collection, id);
    changeRotation(searchedCamera, searchedCamera.asset.extras[0].Position,
         searchedCamera.asset.extras[0].rotation += 25)
}

// 寻找当前id的摄像头
function searchCamera(cameraCollection, index) {
    var camera
    for(let i = 0; i<cameraCollection.length; i++) {
        if(cameraCollection[i].asset.extras[0].Id == index){
            camera = cameraCollection[i]
        }
    }
    return camera
}

export {cameraLeft, cameraRight}